/*====================================================================================
                                                                     
		Financial Constraints and Propagation of Shocks in Production Networks
			    By Demir-Javorcik-Michalski-Ors
  
*====================================================================================*/	

clear all
set more off
log close _all
set matsize 5000

cd "\data\" // Add your directory here

/***************************************
Estimates presented in Figure 1
***************************************/
use tempall.dta,clear

keep if year>2008 & year<2015

local period="  2009 2010 2012 2013 2014"

foreach X in BartikExposure ImpShr0 lnEmp0 {
for Y in any `period': gen `X'xDY=(year==Y)*`X'
}

egen st=group(nace4 year)
egen rt=group(province year)

drop if ChgRUSFShr_fy==.

reghdfe  ChgRUSFShr_fy BartikExposurex* ImpShr0x* lnEmp0x*   ,absorb( sr st rt) vce(cluster sr)
estimates store col1
estadd local FE "sr,st,rt" , replace
estadd local cluster "sr", replace

reghdfe  ChgRUSFShr_fy BartikExposurex* ImpShr0x* lnEmp0x* if LiqCons==0  ,absorb( sr st rt) vce(cluster sr)
estimates store col2
estadd local FE "sr,st,rt" , replace
estadd local cluster "sr", replace

reghdfe  ChgRUSFShr_fy BartikExposurex* ImpShr0x* lnEmp0x* if LiqCons==1   ,absorb( sr st rt) vce(cluster sr)
estimates store col3
estadd local FE "sr,st,rt" , replace
estadd local cluster "sr", replace

reghdfe  ChgCIAShr_fy  BartikExposurex* ImpShr0x* lnEmp0x* ,absorb( sr st rt) vce(cluster sr)
estimates store col4
estadd local FE "sr,st,rt" , replace
estadd local cluster "sr", replace

reghdfe  ChgCIAShr_fy  BartikExposurex* ImpShr0x* lnEmp0x* if  LiqCons==0,absorb( sr st rt) vce(cluster sr)
estimates store col5
estadd local FE "sr,st,rt" , replace
estadd local cluster "sr", replace

reghdfe  ChgCIAShr_fy  BartikExposurex* ImpShr0x* lnEmp0x* if  LiqCons==1 ,absorb( sr st rt) vce(cluster sr)
estimates store col6
estadd local FE "sr,st,rt" , replace
estadd local cluster "sr", replace

reghdfe  ChgSLCShr_fy  BartikExposurex* ImpShr0x* lnEmp0x* ,absorb( sr st rt) vce(cluster sr)
estimates store col7
estadd local FE "sr,st,rt" , replace
estadd local cluster "sr", replace

reghdfe  ChgSLCShr_fy  BartikExposurex* ImpShr0x* lnEmp0x* if LiqCons==0 ,absorb( sr st rt) vce(cluster sr)
estimates store col8
estadd local FE "sr,st,rt" , replace
estadd local cluster "sr", replace

reghdfe  ChgSLCShr_fy  BartikExposurex* ImpShr0x* lnEmp0x* if LiqCons==1 ,absorb( sr st rt) vce(cluster sr)
estimates store col9
estadd local FE "sr,st,rt" , replace
estadd local cluster "sr", replace

esttab col1 col2 col3 col4 col5 col6 col7 col8 col9, compress width(1\hsize)  se  star(* 0.10 ** 0.05 *** 0.01) s(N r2 cluster   FE )
